//
//  BLApi.h
//  BasketBallLeagues
//
//  Created by kenshin on 4/25/17.
//  Copyright © 2017 kenshin. All rights reserved.
//

#import <Foundation/Foundation.h>

#import "KSNetworking.h"
#import "KSNetworkDefines.h"
#import "BLBaseRequestGet.h"
#import "BLBaseRequestPost.h"

typedef void (^BLAPICommonSucccessBlock)(BLBaseResponse *response, id responseDataOriginal);
typedef void (^BLAPICommonErrorBlock)(BLBaseResponse *response, id responseDataOriginal, NSError *error);


@interface BLExampleCommentSupport : KSBaseRequestParam

@property (nonatomic) NSInteger commentID;

@end

@interface BLApi : NSObject


#pragma mark - 初步封装
+ (void)commonGET:(nonnull NSString *)URLString
       parameters:(nullable NSDictionary *)parameters
          success:(nullable BLAPICommonSucccessBlock)successBlock
           failed:(nullable BLAPICommonErrorBlock)failedBlock;

+ (void)commonGET:(NSString *)URLString
       parameters:(NSDictionary *)parameters
       completion:(BLAPICommonSucccessBlock)completion;

+ (void)commonPOST:(nonnull NSString *)URLString
        parameters:(nullable NSDictionary *)parameters
           success:(nullable BLAPICommonSucccessBlock)successBlock
            failed:(nullable BLAPICommonErrorBlock)failedBlock;

+ (void)commonPOST:(NSString *)URLString
        parameters:(NSDictionary *)parameters
        completion:(BLAPICommonSucccessBlock)completion;

//通用get请求
+ (BLBaseRequestGet *)GET:(NSString *)URLString
               parameters:(NSDictionary *)parameters
              decodeClass:(Class)decodeClass
               completion:(KSRequestCompletionBlock)completion;

+ (BLBaseRequestGet *)GET:(NSString *)URLString
               paramModel:(KSBaseRequestParam *)paramModel
              decodeClass:(Class)decodeClass
               completion:(KSRequestCompletionBlock)completion;

//通用post请求
+ (BLBaseRequestPost *)POST:(NSString *)URLString
                 parameters:(NSDictionary *)parameters
                decodeClass:(Class)decodeClass
                 completion:(KSRequestCompletionBlock)completion;

+ (BLBaseRequestPost *)POST:(NSString *)URLString
                 paramModel:(KSBaseRequestParam *)paramModel
                decodeClass:(Class)decodeClass
                 completion:(KSRequestCompletionBlock)completion;


+ (void)startRequest:(BLBaseRequest *)request
         decodeClass:(Class)decodeClass
          completion:(KSRequestCompletionBlock)completion;

// example:参数字典
+ (void)exampleCommentSupportByDict:(NSInteger)commentID;

/**
 example:参数为model
 
 @param commentSupportParam 请求参数为一个model
 
 适用场景：
 1. 更清晰更结构化的参数定义
 2. 减少参数传递个数
 */
+ (void)exampleCommentSupport:(BLExampleCommentSupport *)commentSupportParam;



/**
 长传图片文件
 
 @param url url
 @param image 图片
 @param params 参数
 @param didFinishBlock 回调
 */
+(void) PostImageToUrl:(NSString *)url
                 image:(NSData *)imageData
                Params:(NSDictionary *)params
             didFinish:(void(^)(id json,NSError *error))didFinishBlock;

/**
 *  上传多张图片到服务器
 *  @param url            url
 *  @param params         参数
 *  @param imageDatas     data数组
 *  @param didFinishBlock 回调
 */
+(void)PostImagesToUrl:(NSString *)url
             SetParams:(NSDictionary *)params
            ImageDatas:(NSMutableArray *)imageDatas
             didFinish:(void(^)(id json,NSError *error))didFinishBlock;

+ (NSString *)configSign:(NSString *)userId andCurtime:(NSString *)curtime;
@end
